package com.ruoyi.appraisal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appraisal.domain.HouseAppraisal;
import com.ruoyi.appraisal.service.IHouseAppraisalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房屋估价Controller
 * 
 * @author ruoyi
 * @date 2025-11-09
 */
@RestController
@RequestMapping("/appraisal/houseAppraisal")
public class HouseAppraisalController extends BaseController
{
    @Autowired
    private IHouseAppraisalService houseAppraisalService;

    /**
     * 查询房屋估价列表
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseAppraisal houseAppraisal)
    {
        startPage();
        List<HouseAppraisal> list = houseAppraisalService.selectHouseAppraisalList(houseAppraisal);
        return getDataTable(list);
    }

    /**
     * 导出房屋估价列表
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:export')")
    @Log(title = "房屋估价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseAppraisal houseAppraisal)
    {
        List<HouseAppraisal> list = houseAppraisalService.selectHouseAppraisalList(houseAppraisal);
        ExcelUtil<HouseAppraisal> util = new ExcelUtil<HouseAppraisal>(HouseAppraisal.class);
        util.exportExcel(response, list, "房屋估价数据");
    }

    /**
     * 获取房屋估价详细信息
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(houseAppraisalService.selectHouseAppraisalById(id));
    }

    /**
     * 新增房屋估价
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:add')")
    @Log(title = "房屋估价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseAppraisal houseAppraisal)
    {
        return toAjax(houseAppraisalService.insertHouseAppraisal(houseAppraisal));
    }

    /**
     * 修改房屋估价
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:edit')")
    @Log(title = "房屋估价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseAppraisal houseAppraisal)
    {
        return toAjax(houseAppraisalService.updateHouseAppraisal(houseAppraisal));
    }

    /**
     * 删除房屋估价
     */
    @PreAuthorize("@ss.hasPermi('appraisal:houseAppraisal:remove')")
    @Log(title = "房屋估价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseAppraisalService.deleteHouseAppraisalByIds(ids));
    }
}
